<?php

require_once 'phpmoko/ui/Form/FormBase.php';

class RadioButton extends FormBase
{
	private $enabled = true;
	private $label;
	private $value = false;
	
	function __construct($name, $label)
	{
		parent::__construct();
		
		$this->label = $label;
		$this->name = $name;
	}
	
	function setEnabled($enabled)
	{
		$this->enabled = $enabled;
	}
	
	function setValue($value)
	{
		$this->value = $value;
	}
	
	function toString()
	{
		$str = '<span class="pmk-RadioButton';

		if (!$this->enabled)
			$str .= ' pmk-RadioButton-disabled';

		$str .= '">';
		
		$str .= '<input';

		$str .= ' type="radio"';

		if (!$this->enabled)
			$str .= ' disabled="disabled"';

		if ($this->name != null)
			$str .= ' name="'.$this->name.'"';

		if ($this->id != null)
			$str .= ' id="'.$this->id.'"';
		
		if ($this->value)
			$str .= ' checked="checked"';
		
		$str .= '>';
		
		$str .= '<label for="'.$this->id.'">'.$this->label.'</label>';
		
		$str .= '</span>';

		return $str;
	}
}
?>